JavaScript

A5.audio.Playerload Method

Syntax

A5.audio.Player.load(src)

Arguments

srcstringarray

The source of the audio file to play, the player will choose the first source it can play if the source is an array.

Description

Load an audio file to play.

Example: Loading an Audio File into the AudioPlayer Control

You can dynamically load an audio file into the AudioPlayer control in the UX Component using the load() method on the _play object of the AudioPlayer control's JavaScript object. For example:

// Get the object for the AudioPlayer Control:
var audioObj = {dialog.object}.getControl('AUDIOPLAYER');
            
var audioFile = "http://alphamediacapture.s3.amazonaws.com/myrecording.m4a";

if (audioObj) {
    // the audio player class object is stored in the _play
    // property of the AudioPlayer Control's JavaScript object:
    audioObj._play.load(audioFile);
}
The AudioRecorderAndPlayer control's JavaScript object also has a _play property containing methods for the audio player class.

Using load() to set the audio file, however, is not necessary. Because the AudioPlayer control is a Data Control in the UX Component, you can use {dialog.object}.setValue() to load an audio file instead of the load() method. EG:

var audioFile = "http://alphamediacapture.s3.amazonaws.com/myrecording.m4a";
{dialog.object}.setValue('AUDIOPLAYER',audioFile);

See Also